const Base = require('../base.js');

module.exports = class extends Base {
  /// 获取广告配置
  async indexAction() {
    const db = this.mongoose('mongo/ad_config')
    let adconfig = await db.findOne({})
    if (!adconfig) {
        adconfig = {
          image: '',
          link: ''
        }
        let doc = new db(adconfig)
        await doc.save()
    }
    this.json({
      status: 200,
      message: 'success',
      data: adconfig
    })
  }
};
